# 这里进行交易接口测试,购买一张多单下单
# if test:
#     loss_point = current_price*0.95
#     attachAlgoOrds = []
#     attachorder_dict = {}
#     # attachorder_dict['attachAlgoClOrdId'] = '202301'
#     # attachorder_dict['tpTriggerPx'] = None
#     # attachorder_dict['tpOrdPx'] = None
#     # attachorder_dict['slOrdPx'] = str(loss_point)
#     # attachorder_dict['slTriggerPx'] = str(loss_point)
#     attachAlgoOrds.append(attachorder_dict)
#     td_response = trade_action_new(tradeAPI,
#                                instId,
#                                side = 'buy',
#                                sz = 1,
#                                px = str(current_price),
#                                attachAlgoOrds = None)
#     # td_response = trade_action(tradeAPI,
#     #                            instId,
#     #                            side='buy',
#     #                            sz=1,
#     #                            px=str(current_price),
#     #                            tpTriggerPx=None,  # 止盈触发价格,关闭则不设置止盈
#     #                            tpOrdPx=None,
#     #                            slOrdPx=str(loss_point),
#     #                            slTriggerPx=str(loss_point)
#     #                            )
#     if len(td_response['data'])>0:
#         order_id = td_response['data'][0]['ordId']
#         # 获取订单是否成交状态
#         get_order_result = order_get(tradeAPI,instId,order_id)
#         # 订单成交
#         # if get_order_result[0]['state'] == "filled":
#         if True:
#             # 设置止损订单
#             attachAlgoOrds = []
#             attachorder_dict = {}
#             # attachorder_dict['attachAlgoClOrdId'] = '202301'
#             attachorder_dict['tpTriggerPx'] = None
#             attachorder_dict['tpOrdPx'] = None
#             attachorder_dict['slOrdPx'] = str(loss_point)
#             attachorder_dict['slTriggerPx'] = str(loss_point)
#             attachAlgoOrds.append(attachorder_dict)
#             sz = 1,
#             change_response = strategy_order(tradeAPI,
#                                            instId = instId,
#                                            side='sell',
#                                              sz = 1,
#                                             tpTriggerPx=None,  # 止盈触发价格,关闭则不设置止盈
#                                             tpOrdPx=None,
#                                             slOrdPx=str(loss_point),
#                                             slTriggerPx=str(loss_point)
#                                            )
#             algoId = change_response['data'][0]['algoId']
#             change_order_response = strategy_order_change(tradeAPI,
#                                                           instId = instId,
#                                                           algoId = algoId,
#                                                           newSlTriggerPx=str(loss_point/2))